﻿
@{
    ViewBag.Title = "客户存货汇总报表";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}

<table id="dg" class="easyui-datagrid" style="width:100%; height: 750px;" toolbar="#tb" title="客户存货汇总报表" rownumbers="true" pagination="false" fitcolumns="true" singleselect="true" showFooter="true">
    @*<thead>
            <tr>
                <th field="CustomerNo" align="right" width="80">
                    客户编号
                </th>
                <th field="CustomerName" align="right" width="80">
                    客户名称
                </th>
                <th field="Total" align="right" width="80">
                    存货件数
                </th>
                <th field="TotalTon" align="right" width="80" formatter="formatter_TotalTon">
                    存货吨重
                </th>
            </tr>
        </thead>*@
</table>
<div id="tb" style="padding: 3px; height: auto;">
    <span>仓库</span>
    <input id="SelectWareHouseId" class="easyui-combobox" style="width: 173px; height: 30px;" />
    <span>汇总日期</span>
    <input class="easyui-datebox" name="SummaryTime" id="SummaryTime" style="width: 173px; height: 30px; ">
    <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="doSearch()">查询</a>
    <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-sum" onclick="doExport()">导出</a>
</div>
<script src="~/Js/Global.js?v=20240701"></script>
<script language="javascript" type="text/javascript">
    $(function () {
        InitSelectWareHouse();
        initgrid();
    });

    function initgrid() {
        $('#dg').datagrid({
            url: '/Report/GetCustomerInventorySummaryReport',
            showFooter: true,
            columns: [[
                { field: 'CustomerNo', title: '客户编号', width: 80, align: 'right' },
                { field: 'CustomerName', title: '客户名称', width: 80, align: 'right' },
                { field: 'Total', title: '存货件数', width: 80, align: 'right' },
                { field: 'TotalTon', title: '存货吨重', width: 80, align: 'right', formatter: formatter_TotalTon }
            ]],
            // 设置footer行的配置
            footer: [
                { field: 'CustomerNo', title: '' },
                { field: 'CustomerName', title: '' },
                { field: 'Total', title: 'Total' },
                { field: 'TotalTon', title: 'TotalTon' }
                // 其他列...
            ],
            onLoadSuccess: function (data) {
                //var TotalSummary = data.rows.reduce(function (sum, row) {
                //    return sum + row.age;
                //}, 0);
                //$('#dg').datagrid('reloadFooter', {
                //    Total: { value: TotalSummary }
                //});
            }
        });
    }

    function doSearch() {
        $('#dg').datagrid('load', {
            WareHouseId: $('#SelectWareHouseId').combobox('getValue'),
            SummaryTime: $('#SummaryTime').datebox('getValue')
        });
    }

    function doExport() {
        var houseid = $('#SelectWareHouseId').combobox('getValue');
        var summarytime = $('#SummaryTime').datebox('getValue');
        //window.open('@Url.Content("~/Report/ExportCustomerInventorySummaryReport")');
        window.open('@Url.Content("~/Report/ExportCustomerInventorySummaryReport")' + '?houseId=' + houseid + "&summartTime=" + summarytime);
    }

    function formatter_TotalTon(value, rowData, rowIndex) {
        return rowData.TotalTon.toFixed(4);
    }


</script>

